using UnityEngine;
using UnityEngine.EventSystems;

namespace Game.UI {
	public sealed class HintShower : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler {
		public string HintText;
		public Vector2 Offset = Vector2.zero;
		public RectTransform Origin;

		public HintView HintPrefab;

		HintView _inst;

		public void OnPointerEnter(PointerEventData eventData) {
			if ( !_inst) {
				_inst = Instantiate(HintPrefab, Origin, false);
				_inst.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
			}
			_inst.SetupHint(HintText, Offset);
		}

		public void OnPointerExit(PointerEventData eventData) {
			if ( !_inst) {
				return;
			}
			_inst.HideHint();
		}
	}
}

